import java.util.LinkedList;
import java.util.Queue;

public class Demofs14 {
    boolean isCompleteTree(BinaryTree.TreeNode root) {

        Queue<BinaryTree.TreeNode> queue = new LinkedList<>();
        queue.add(root);
        while(!queue.isEmpty()){
            BinaryTree.TreeNode ret =queue.poll();
            if(ret != null){
                queue.offer(ret.left);
                queue.offer(ret.right);
            }
            else {
                break;
            }
        }
        while(!queue.isEmpty())
        {
            if(queue.poll() != null){
                return false;
            }
        }
        return true;
    }
}
